package org.activiti.designer.test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.HistoryService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment;
import org.junit.Test;


public class ProcessTestNoUserMultiTask extends AbstractTest {



	@Test
	@Deployment(resources={"diagrams/chapter9/NoUserMultiTask.bpmn"})
	public void startProcess() throws Exception {
		Map<String, Object> variableMap = new HashMap<String, Object>();
		variableMap.put("loop", 3);
		variableMap.put("counter", 0);
		ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("NoUserMultiTask", variableMap);
		
		TaskService taskService = activitiRule.getTaskService();
		List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
		System.out.println(tasks.size());
		//Object variable = runtimeService.getVariable(processInstance.getId(), "counter");
		long count = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).count();
		System.out.println(count);
//		assertEquals(3, variable);
		System.out.println("id " + processInstance.getId() + " "
				+ processInstance.getProcessDefinitionId());
	}
}